package com.sky.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.sky.annotation.AutoFill;
import com.sky.dto.SetmealPageQueryDTO;
import com.sky.entity.Setmeal;
import com.sky.enumeration.OperationType;
import com.sky.vo.DishItemVO;
import com.sky.vo.SetmealVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SetmealMapper extends BaseMapper<Setmeal> {

    // 新增套餐
    @AutoFill(value = OperationType.INSERT)
    void insertSetmeal(Setmeal setmeal);

    // 套餐分页查询
    List<SetmealVO> pageQuery(SetmealPageQueryDTO dto);

    // 删除套餐
    Integer deleteByIds(List<Long> ids);

    // 根据id查询套餐
    @Select("select * from setmeal where id = #{id}")
    SetmealVO selectById(Long id);

    // 修改套餐
    @AutoFill(value = OperationType.UPDATE)
    void update(Setmeal setmeal);

    // 根据分类id查询菜品
    @Select("select * from setmeal where category_id = #{categoryId}")
    List<Setmeal> selectByCategoryId(Integer categoryId);


    List<DishItemVO> selectBySetmealId(Integer setmealId);

    @Select("select * from setmeal where category_id = #{categoryId} and status = 1")
    List<Setmeal> userSelectByCategoryId(Integer categoryId);
}
